home *** CD-ROM | disk | FTP | other *** search
Text File | 1992-11-03 | 1.2 KB | 65 lines | [TEXT/MPS ] |
- C NewRes.f is an example of how to use Toolbox calls
- C to create, write to, and read from the resource fork
- C of a file. ResEdit or some sort of resource editor
- C may be useful for viewing the file you create.
-
- C Example provided for owners of Language Systems FORTRAN
- C © 1992 Language Systems Corp.
-
- !!G Toolbox.finc
- !!MP Inlines.f
-
- program sinped
-
- record /StringHandle/ aStr
- integer*2 theResFile
- integer*2 IDnum
- string*255 astring
-
- string*255 filename
-
- OPEN ( 83,
- 1 FILE = *,
- 2 ACCESS = 'DIRECT',
- 3 FORM = 'UNFORMATTED',
- 4 RECL = 8192,
- 5 STATUS = 'NEW',
- 6 FILETYPE = 'Sd2f',
- 7 CREATOR = 'Appl',
- 8 ERR = 803)
-
- INQUIRE(83,NAME=filename)
-
- call CreateResFile(filename)
- theResFile = OpenResFile(filename)
-
- IDnum = 1001
- astring = '\p23456789'
- aStr = NewString(astring)
-
- astring = '\psample-size'
- call AddResource(aStr,'STR ',IDnum,astring)
-
- call WriteResource(aStr)
- call UpdateResFile(theResFile)
- call CloseResFile(theResFile)
-
- CLOSE (83)
-
- C Try to read the resource
-
- astring = ' '
- theResFile = OpenResFile(filename)
- IDnum = 1001
- aStr = GetString(IDnum)
-
- astring = aStr.H^.P^
- write(*,*) 'astring = ',astring
-
- call CloseResFile(theResFile)
- STOP 'NORMAL EXIT'
-
- 803 CONTINUE
- STOP 'ERROR OPENING OUTPUTFILE'
-
- END